package core.android.views.grid;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

/**
 * @作者: XQ
 * @创建时间：2016/1/17 15:25
 * @类说明:用于嵌套在Scrollview listview 等控件中。解决GridView,ListView嵌套在ScrollView时只显示一行高度的问题
 */
public class GridViewForScrollView extends GridView {
    public GridViewForScrollView(Context context) {
        this(context, null);
    }

    public GridViewForScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // Do not use the highest two bits of Integer.MAX_VALUE because they are
        // reserved for the MeasureSpec mode
        int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, heightSpec);
    }
}
